package com.erp.gather.controller;

import com.erp.gather.service.AliexpressCategoryService;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.gather.api.domain.Aliexpress;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@RequiredArgsConstructor
@RequestMapping("aliexpress/category")
@RestController
public class AliexpressCategoryController {

    private final AliexpressCategoryService service;

    @RequestMapping(value = "saveAliexpressCategory", method = RequestMethod.GET)
    public R<List<Aliexpress.AliexpressCategoryResponse>> saveAliexpressCategory(Long skip, Long limit, HttpServletRequest request) {
        service.saveAliexpressCategory();
        return R.ok();
    }
    @RequestMapping(value = "getCategoryInfoById", method = RequestMethod.GET)
    public R<List<Aliexpress.CategoryInfoVo>> getCategoryInfoById(Long id) {
        List<Aliexpress.CategoryInfoVo> list = service.getCategoryInfoById(id, false);
        return R.ok(list);
    }

    @GetMapping("/getCategoryInfoByIdInner/{categoryId}")
    public R<Object> getCategoryInfoByIdInner(@PathVariable("categoryId") Long categoryId) {
        List<Aliexpress.CategoryInfoVo> list = service.getCategoryInfoById(categoryId, false);
        return R.ok(list);
    }

    @RequestMapping(value = "getBrandById", method = RequestMethod.GET)
    public R<List<Aliexpress.ValueVo>> getBrandById(Long categoryId, Long storeId) {
    	List<Aliexpress.ValueVo> list = service.getBrandById(categoryId, storeId);
    	return R.ok(list);
    }

    @RequestMapping(value = "updateProductAttributesById", method = RequestMethod.GET)
    public R<Void> updateProductAttributesById(Long id) {
        service.updateProductAttributesById(id);
        return R.ok();
    }
}
